package com.fenghongzhang.music.broadcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.fenghongzhang.music.fragment.MusicFragment;
import com.fenghongzhang.music.util.BroadcastConst;

public class MusicReceiver extends BroadcastReceiver {

    private static final String TAG = "MusicReceiver";
    @Override
    public void onReceive(Context context, Intent intent) {
        //你的广播是否正确的被注册.
        Log.i(TAG, "onReceive: ");

        String action = intent.getAction();
        if(BroadcastConst.PAUSE.equals(action)){
            //发送一个让音乐停止的指令
            MusicFragment.handler.sendEmptyMessage(101);
        }else if("com.feng.restart".equals(action)){
            MusicFragment.handler.sendEmptyMessage(102);
        }

    }
}
